<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <canvas id="canvas" style="border: 1px solid #aaa; display: block; margin: 50px auto;">
        当前浏览器不支持Canvas，请更换浏览器
    </canvas>
    <script>
        window.onload = function () {
            var canvas = document.getElementById("canvas");

            canvas.width = 800;
            canvas.height = 800;

            var context = canvas.getContext("2d");

            context.beginPath();
            context.moveTo(100, 350);
            context.lineTo(500, 350);
            context.lineTo(500, 200);
            context.lineTo(700, 400);
            context.lineTo(500, 600);
            context.lineTo(500, 450);
            context.lineTo(100, 450);
            context.closePath();    //绘制封闭的图形

            context.lineWidth = 10;
            context.fillStyle = 'yellow';   //填充色
            context.strokeStyle = '#058';

            context.fill(); //完成填充
            context.stroke();   //完成绘制
        }
    </script>
</body>
</html>